<link rel="stylesheet" type="text/css" href="__ROOT__/Apps/Home/View/default/css/cart.css" />
<script src="__ROOT__/Apps/Home/View/default/js/userlogin.js"></script>
<script type="text/javascript" src="__ROOT__/Apps/Home/View/default/js/cart/common.js?v=725"></script>
<script type="text/javascript" src="__ROOT__/Apps/Home/View/default/js/cart/quick_links.js"></script>
<!--[if lte IE 8]>
<script src="__ROOT__/Apps/Home/View/default/js/cart/ieBetter.js"></script>
<![endif]-->
<script src="__ROOT__/Apps/Home/View/default/js/cart/parabola.js"></script>
<!--右侧贴边导航quick_links.js控制-->
	<div id="flyItem" class="fly_item" style="display:none;">
		<p class="fly_imgbox">
		<img src="__ROOT__/Apps/Home/View/default/images/item-pic.jpg"
			width="30" height="30">
		</p>
	</div>
	<div class="mui-mbar-tabs">
		<div class="quick_link_mian">
			<div class="quick_links_panel">
				<div id="quick_links" class="quick_links">
					<li id="userHeader"><a href="#" class="my_qlinks" style="margin-top: 5px;"><i class="setting"></i></a>
						<div class="ibar_login_box status_login">
							<if condition="$WST_USER['userId'] gt 0">
							<div class="avatar_box">
								<p class="avatar_imgbox">
									<?php if($WST_USER['userPhoto']!=''){ ?>
									<img src="__ROOT__/{$WST_USER['userPhoto']}" />
									<?php }else{ ?>
									<img src="__ROOT__/Apps/Home/View/default/images/no-img_mid_.jpg" />
									<?php } ?>
								</p>
								<if condition="$WST_USER['userId'] gt 0">
								<ul class="user_info">
									<li>用户名：{$WST_USER['loginName']}</li>
									<li>级&nbsp;别：普通会员</li>
								</ul>
								</if>
							</div>
							
							<div class="ibar_recharge-btn">
								<input type="button" value="我的订单" onclick="getMyOrders();"/>
							</div>
							<i class="icon_arrow_white"></i>
						</div>
						</if></li>
					<li id="shopCart"><a href="#" class="message_list"><i class="message"></i>
					<div class="span">购物车</div> <span class="cart_num">0</span></a></li>
					<if condition="$CONF['qqNo'] neq ''">
					<li>
						<a href="tencent://message/?uin={$CONF['qqNo']}&Site=QQ交谈&Menu=yes" style="padding-top:5px;padding-bottom:5px;margin-bottom: 5px;">
						<img src="__ROOT__/Apps/Home/View/default/images/qq.jpg"  height="38" width="40" />
						</a>
					</li>
					</if>
				</div>
				<div class="quick_toggle">
					<li><a href="#none"><i class="mpbtn_qrcode"></i></a>
						<div class="mp_qrcode" style="display: none;">
							<img
								src="__ROOT__/Apps/Home/View/default/images/wstmall_weixin.png"
								width="148"  /><i class="icon_arrow_white"></i>
						</div>
					</li>
					<li><a href="#top" class="return_top"><i class="top"></i></a></li>
				</div>
			</div>
			<div id="quick_links_pop" class="quick_links_pop hide"></div>
		</div>
	</div>
	<script type="text/javascript">
	var numberItem = {:WSTCartNum()};
	$('.cart_num').html(numberItem);
	
	<PHP>if(session('WST_USER.userId')>0){</PHP>
	$(".quick_links_panel li").mouseenter(function() {
		getVerify();
		$(this).children(".mp_tooltip").animate({
			left : -92,
			queue : true
		});
		$(this).children(".mp_tooltip").css("visibility", "visible");
		$(this).children(".ibar_login_box").css("display", "block");
	});
	$(".quick_links_panel li").mouseleave(function() {
		$(this).children(".mp_tooltip").css("visibility", "hidden");
		$(this).children(".mp_tooltip").animate({
			left : -121,
			queue : true
		});
		$(this).children(".ibar_login_box").css("display", "none");
	});
	<PHP>}else{</PHP>
	$("#userHeader,#shopCart").click(function() {
		loginWin();
	});
	
	<PHP>}</PHP>
	$(".quick_toggle li").mouseover(function() {
		$(this).children(".mp_qrcode").show();
	});
	$(".quick_toggle li").mouseleave(function() {
		$(this).children(".mp_qrcode").hide();
	});

	// 元素以及其他一些变量
	var eleFlyElement = document.querySelector("#flyItem"), eleShopCart = document
			.querySelector("#shopCart");
	eleFlyElement.style.visibility = "hidden";
	
	var numberItem = 0;
	// 抛物线运动
	var myParabola = funParabola(eleFlyElement, eleShopCart, {
		speed : 100, //抛物线速度
		curvature : 0.0012, //控制抛物线弧度
		complete : function() {
			eleFlyElement.style.visibility = "hidden";
			jQuery.post(Think.U('Home/Cart/getCartInfo') ,{"axm":1},function(data) {
				var cart = WST.toJson(data);	
				var totalmoney = 0, goodsnum = 0;
				for(var shopId in cart.cartgoods){
					var shop = cart.cartgoods[shopId];
					for(var goodsId in shop.shopgoods){
						var goods = shop.shopgoods[goodsId];
						goodsnum++;
						totalmoney = totalmoney + parseFloat(goods.shopPrice * goods.cnt);
						totalmoney = totalmoney.toFixed(2);
						
					}
				}
				$(".cart_num").html(goodsnum);
				$(".wst-nvg-cart-price").html(totalmoney);
			});
			
		}
	});
	// 绑定点击事件
	if (eleFlyElement && eleShopCart) {
		[].slice
				.call(document.getElementsByClassName("btnCart"))
				.forEach(
						function(button) {
							button
									.addEventListener(
											"click",
											function(event) {
												// 滚动大小
												var scrollLeft = document.documentElement.scrollLeft
														|| document.body.scrollLeft
														|| 0, scrollTop = document.documentElement.scrollTop
														|| document.body.scrollTop
														|| 0;
												eleFlyElement.style.left = event.clientX
														+ scrollLeft + "px";
												eleFlyElement.style.top = event.clientY
														+ scrollTop + "px";
												eleFlyElement.style.visibility = "visible";
												$(eleFlyElement).show();
												// 需要重定位
												myParabola.position().move();
											});
						});
	}

	function getMyOrders(){
		document.location.href = ThinkPHP.U("Home/Orders/queryByPage");
	}
	
	function removeCartGoods(obj,goodsId,goodsAttrId){
		jQuery.post(Think.U('Home/Cart/delCartGoods') ,{goodsId:goodsId,goodsAttrId:goodsAttrId},function(data) {
			var cart = WST.toJson(data);	
			$(obj).parent().parent().parent().remove();
			var totalmoney = 0, goodsnum = 0;
			for(var shopId in cart.cartgoods){
				var shop = cart.cartgoods[shopId];
				for(var goodsId in shop.shopgoods){
					var goods = shop.shopgoods[goodsId];
					goodsnum++;
					totalmoney = totalmoney + parseFloat(goods.shopPrice * goods.cnt);
					totalmoney = totalmoney.toFixed(2);
				}
			}
			$("#cart_handler_right_totalmoney, .wst-nvg-cart-price").html(totalmoney);
			$('.cart_num').html(goodsnum);
			$(".cart_gnum").html(goodsnum);

		});	
	}
</script>